package com.neo.scalaCookBook.C1_String

/**
  * Autuor : zhaoshun
  * Time   : 2017/10/17 21:55
  * Email  : tmby1314@163.com  
  */

/**
  * what are you to do something, describe it
  */
object StringCharDeal {

  /**
    *
    * @param args
    */
  def main(args: Array[String]): Unit = {

    println("处理字符串，将其转换为大写")
    val upper = "Hello, world".map(c => c.toUpper)
    println(upper)

    val upper1 = "hello, world".map(_.toUpper)
    println(upper1)
    println("对字符串中的字符过滤并处理")
    val upper2 = "Hello world".filter(_ !='l').map(_.toUpper)
    println(upper2)

    println("使用for,yield")
    val upper3 = for(c <- "hello,world") yield c.toUpper
    println(upper3)

    println("使用for,yield 过滤")
    val result = for{
      c <- "hello, world"
      if c != 'l'
    } yield c.toUpper
    println(result)
  }
}
